Skip to content

fix(mactrack): correct xform_mac_address typo and resolver/VLAN logic bugs - #342

Merged
TheWitness merged 1 commit into
Cacti:developfrom
somethingwithproof:fix/mactrack-logic-bugs-clean
Aug 31, 2026
Merged

fix(mactrack): correct xform_mac_address typo and resolver/VLAN logic bugs#342
TheWitness merged 1 commit into
Cacti:developfrom
somethingwithproof:fix/mactrack-logic-bugs-clean

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Extracts the mactrack logic-bug fixes from #333 as a focused, single-purpose change. That PR also bundles a vendored Net/DNS2 tree and regenerated locale files, which belong in separate PRs.

Fixes

  • xform_mac_address(): repair the $max_address/$mac_address typo that discarded the trimmed and normalized value, so MAC formatting returns the correct result instead of a stale one.
  • mactrack_resolver.php: correct the inverted $use_resolver/$resolver assignment (a resolver was built only when no nameservers were configured, and skipped when they were).
  • Vendor driver libs (extreme, foundry, hp, hp_ng, hp_ngi, juniper, enterasys, norbay, norbay_ng): remove the stray $active_vlans++ increment on the $active_vlans array during VLAN scanning.
  • poller_mactrack.php, mactrack_devices.php, mactrack_scanner.php: related MAC-transform and MacAuth-schedule corrections.

Verification

  • php -l clean on all changed files.
  • New Pest test tests/Pest/Unit/XformMacAddressTest.php covers the MAC transform and guards the production source against the typo regression; full suite passes.

… bugs

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

@TheWitness TheWitness left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might create a regression with Active VLANS. However, to be honest, I don't know why I added those there. I thought that there were several vlans, but it seems you could just do a cacti_sizeof() to get that. I wrote this shit when I was barely a junior PHP coder and it showed.

@TheWitness
TheWitness merged commit 38bf1c0 into Cacti:develop Aug 31, 2026
12 checks passed
@somethingwithproof

Copy link
Copy Markdown
Member Author

When @bmfmancini has his lab available. I will make a note to ask him to test.

@jdcoats

jdcoats commented Aug 31, 2026

Copy link
Copy Markdown

I have a modest production environment that I may be able to help test with. Its 284 devices and 36K+ interfaces

@somethingwithproof

Copy link
Copy Markdown
Member Author

@jdcoats that would be helpful. Thank you.

If you have any future requests, let me know thank

@jdcoats

jdcoats commented Aug 31, 2026

Copy link
Copy Markdown

funny you mention that :) #152 has been around a while, integrate "sites" and not use separate Cacti and Mactrack sites.

@jdcoats

jdcoats commented Sep 1, 2026

Copy link
Copy Markdown
2026/09/01 09:38:26 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'mactrack'
2026/09/01 09:38:26 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler())
2026/09/01 09:38:26 - ERROR PHP ERROR in Plugin 'mactrack': Uncaught Error: Failed opening required '/var/www/localhost/htdocs/cacti/plugins/mactrack/vendor/autoload.php' (include_path='.:/usr/share/php7:/usr/share/php:/var/www/localhost/htdocs/cacti:/var/www/localhost/htdocs/cacti/:/var/www/localhost/htdocs/cacti/') in /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php:45 Stack trace: #0 {main} thrown in file: /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php on line: 45
2026/09/01 09:38:26 - CMDPHP PHP ERROR WARNING Backtrace: (/plugins/mactrack/mactrack_resolver.php[45]:require_once(), /plugins/mactrack/mactrack_resolver.php[45]:CactiErrorHandler())
2026/09/01 09:38:26 - ERROR PHP WARNING in Plugin 'mactrack': require_once(/var/www/localhost/htdocs/cacti/plugins/mactrack/vendor/autoload.php): Failed to open stream: No such file or directory in file: /var/www/localhost/htdocs/cacti/plugins/mactrack/mactrack_resolver.php on line: 45

@TheWitness

Copy link
Copy Markdown
Member

@somethingwithproof, no composer.json in Plugin Directories.

@somethingwithproof

Copy link
Copy Markdown
Member Author

@TheWitness understood. #345 drops composer.json and ships Net_DNS2 under Net/ again, the same way plugin_flowview does.

@jdcoats that PR is the fix for the fatal you hit, apologies for the disruption. While you have the lab up, could you check whether Active VLANs still populates on your Cisco devices? #342 removed a stray $active_vlans++ from the vendor libs and I would rather have that confirmed against real hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants